/*
Copyright (C) 1996-1997 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

#include "quakedef.h"
#include "menu.shared.h"


void M_NewSinglePlayerGame (void)
{
	if (sv.active)
	{
		// only show the prompt if a client is still alive; otherwise just go straight to the new game
		for (int i = 0; i < svs.maxclients; i++)
		{
			if (svs.clients[i].active && (svs.clients[i].edict->v.health > 0))
			{
				if (!SCR_ModalMessage ("Are you sure you want to\nstart a new game?\n"))
					return;
				else break;
			}
		}
	}

	m_soundlevel = m_sound_none;
	Key_SetDest (key_game);

	if (sv.active)
		Cbuf_AddText ("disconnect\n");

	Cbuf_AddText ("maxplayers 1\n");
	Cbuf_AddText ("map start\n");
}


class qmenu_singleplayer_t : public qmenu_t
{
public:
	qmenu_singleplayer_t (void)
	{
		// add our options
		this->AddOption (new qmenu_banner_t ("gfx/ttl_sgl.lmp"));
		this->AddOption (new qmenu_divider_t ());

		this->AddOption (new qmenu_chunkypic_t ("gfx/sp_menu.lmp"));
		this->AddOption (new qmenu_plaque_t ());

		this->AddOption (new qmenu_bigaction_t (M_NewSinglePlayerGame));
		this->AddOption (new qmenu_bigsubmenu_t (m_load));
		this->AddOption (new qmenu_bigsubmenu_t (m_save));

		// and register our menu
		this->Register (m_singleplayer);
	}

	void EnterFunc (void)
	{
		this->EnterMenu ();
	}
} menu_singleplayer;


